
				<section id="content" class="grid_7 alpha omega">
					<article>
						
						<div id="feeds">
							<?php foreach($feed as $rows){
									$row = $rows['feed'];
									$id = $row['id'];
							?>
							<div id="feed-<?php echo $row['id']?>" class="news-feed">
								<div class="feed-gravatar">
									<img src='<?php echo base_url()?>images/profile/<?php echo $row['profile_image']?>' height='50' width='50' />
								</div>
								<div class="feed-data">
									<div class="feed-author"><a href="#" class="url"><?php echo $row['nama_user']?></a></div>				
									<p>
									<?php echo nl2br($row['text'])?>
									</p>
									<?php if($row['url'] != ''){?>
									<div class="feed-url">
										<div class="url-image">
											<?php if($row['image'] != ''){?><img src="<?php echo $row['image']?>" class="avatar-gui" height="55px" width="85px" /><?php } ?>
										</div>
										<div class="url-data">
											<div class="url-title"><a href="<?php echo $row['url']?>" class="url" target="_blank"><?php echo $row['title']?></a></div>				
											<p>
											<?php echo substr($row['description'],0,250)?>
											</p>
										</div>
									</div>
									<?php } ?>
									<div class="feed-meta"><a href="javascript:" onClick="viewMessage(this)">Komentar</a> | <a href="<?php echo base_url()."member/post/$row[id]"?>"><abbr title="<?php echo $row['created']?>"></abbr></a></div>
								</div>
								<?php if($rows['comm']->num_rows() > 0){?>
								<ul class="feed-comment">
									<?php foreach($rows['comm']->result_array() as $row){?>
									<li id="comment-<?php echo $row['id']?>">
										<div class="comment-gravatar">
											<img src='<?php echo base_url()?>images/profile/<?php echo $row['profile_image']?>' height='32' width='32' />
										</div>
										<div class="comment-data">			
											<p>
												<span class="comment-author"><a href="#" class="url"><?php echo $row['nama_user']?></a></span>
												<?php echo nl2br($row['text'])?>
											</p>
											<?php if($row['url'] != ''){?>
											<div class="comment-url">
												<div class="url-image">
													<?php if($row['image'] != ''){?><img src="<?php echo $row['image']?>" class="avatar-gui" height="55px" width="85px" /><?php } ?>
												</div>
												<div class="url-data">
													<div class="url-title"><a href="<?php echo $row['url']?>" class="url" target="_blank"><?php echo $row['title']?></a></div>				
													<p>
													<?php echo substr($row['description'],0,250)?>
													</p>
												</div>
											</div>
											<?php } ?>
											<div class="comment-meta"><abbr title="<?php echo $row['created']?>"></abbr></div>
										</div>
									</li>
									<?php } ?>
									<li class="comment-form">
										<form id="commentform-<?php echo $id?>"action="<?php echo base_url()?>member.html" class="styled">
											<input type="hidden" name="data[parent_id]" id="parent_id" value="<?php echo $id?>" /> 
											<textarea class="textbox comm" name="data[text]" id="text" cols="60%" rows="1"></textarea>												
										</form>
									</li>
								</ul>
								<?php } ?>
							</div>
							<?php } ?>
						</div>
					</article>
				</section>
				<section class="cl"></section>
				
<script>
var loadTime='';
var timeTop='<?php echo date("Y-m-d H:i:s")?>';				
$(document).ready(function() {
   $("abbr").timeref();
   loadTime = setInterval(function(){ $("abbr").timeref();loadComment(); }, 10000);
   
   $('.comm').keyup(function(event){
		if(event.keyCode == 13 && !event.shiftKey) {
			var form = $(this).parent();
			submitComm(form);
		}		
	});

});

function viewMessage(msg){
	var parent = $(msg).parent().parent().parent();
	var id= parent.attr('id').replace("feed-","");
	var check = true;
	$(parent).children().each(function(){
		var kid = $(this);
		if(kid.attr('class') == 'feed-comment')
			check = false;
	});
	
	if(check){
		var html = '<ul class="feed-comment">'
				+'<li class="comment-form">'
				+'<form id="commentform-'+id+'" action="<?php echo base_url()."member.html"?>" class="styled">'
				+'<input type="hidden" name="data[parent_id]" id="parent_id" value="'+id+'" />'
				+'<textarea class="textbox comm" name="data[text]" id="text" cols="60%" rows="1"></textarea>'
				+'</form>'
				+'</li>'
				+'</ul>';
				
		parent.append(html);
		
		$('.comm').keyup(function(event){
			if(event.keyCode == 13 && !event.shiftKey) {
				var form = $(this).parent();
				submitComm(form);
			}		
		});
		$('textarea').autogrow();
	}
	
	$(parent).children('.feed-comment').children('.comment-form').children('form').children('#text').focus();
}

function submitComm(form){
	var formInput = $(form).serialize();
	$.ajax({
		url: $(form).attr('action'),
		data: formInput,
		beforeSend : function(){
			$.fancybox.showActivity();
		},
		success: function(respon){
			var obj = jQuery.parseJSON(respon);
			if(obj.status == 'success'){
				$("#"+$(form).attr('id')+" #text").val('');
				var html = getComm(obj);
				form.parent().parent().children('.comment-form').before(html);
				
				$("abbr").timeref();
				
			}else{
				alert('');
			}
			
			$.fancybox.hideActivity();
		},
		type: "POST"
	});
}

function getComm(obj){
	var html = '<li class="'+obj.id+'">'
		   +'<div class="comment-gravatar">'
		   +'<img src="<?php echo base_url()?>images/profile/'+obj.profile_image+'" height="32" width="32" />'
		   +'</div>'
		   +'<div class="comment-data">'				
		   +'<p><span class="comment-author"><a href="#" class="url">'+obj.nama_user+'</a></span> '+obj.text+'</p>';
	
	if(obj.url != ""){
		html = html	+'<div class="comment-url">'
				+'<div class="url-image">';
		if(obj.image != ""){
				html = html	+'<img src="'+obj.image+'" class="avatar avatar-60 photo avatar-gui" height="55px" width="85px" />'
		}		
		html = html	+'</div>'
				+'<div class="url-data">'
				+'<div class="url-title"><a href="'+obj.url+'" class="url">'+obj.title+'</a></div>'			
				+'<p>'+obj.desc+'</p>'
				+'</div>'
				+'</div>';
	}
		
	html = html	+'<div class="comment-meta"><abbr title="'+obj.created+'"></abbr></div>'
			+'</div>'
			+'</li>';
			
	return html;									
}

function loadComment(){

	var time = timeTop;
	
	$.ajax({
		url: "<?php echo base_url()?>member/comment.html",
		data: {time:time},
		beforeSend : function(){

		},
		success: function(respon){
			var obj = jQuery.parseJSON(respon);
			$.each(obj, function(index, data) {
				var id = data.parent_id;
				//console.log($("#comment-"+data.id).length);
				if($("#comment-"+data.id).length == 0){
					//console.log("#commentform-"+id);
					$("#commentform-"+id).parent().before(getComm(data));
					timeTop = data.created;
				}
				
			})
			
			$("abbr").timeref();
			
		},
		type: "POST"
	});
}

</script>